package com.cloud.wyf.Mapper;

import com.cloud.wyf.Entity.Middel;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MiddelMapper {

    @Insert("<script> insert into middel "
            + "(uid,realname,part,position,level) "
            + "values "
            + "<foreach collection = 'list' item='record' separator=',' > "
            + " (#{record.uid},#{record.realname},#{record.part},#{record.position},#{record.level}) "
            + "</foreach>"
            + "</script>")
    int MultiAdd(List<Middel> list);

    @Select("select * from middel")
    List<Middel> selectAllMi();

    @Select("select * from middel where uid=#{uid}")
    Middel selectMidById(String uid);

    @Select("select count(*) from middel")
    int selectTotal();

    @Select("select * from middel limit #{begin},#{size}")
    List<Middel> selectPage(@Param("begin") int begin, @Param("size") int size);

    @Update("update middel set summarypath=#{summarypath},summarytime=now(),status=#{status} where uid=#{uid}")
    int updateS(@Param("uid") String uid,@Param("summarypath") String summarypath,@Param("status")int status);

    @Update("update middel set status=#{status} where uid=#{uid}")
    int updateStatus(@Param("status") int status,@Param("uid") String  uid);

    @Update("<script>update middel set <foreach collection = 'list' item='record' separator=',' >" +
            "part=#{record.part},position=#{record.position},level=#{record.level}</foreach>" +
            "where uid in <foreach collection = 'list' item='record' separator=',' open='(' close=')'>" +
            "#{record.uid}</foreach></script>")
    int updateInfo(List<Middel> list);
}
